/**
 * @Description 回文数
 * @Author hhy
 * @Date 2020/10/26 14:32
 */
public class Palindrome {
    public static void main(String[] args) {
        int num = 123321;
        Palindrome palindrome = new Palindrome();

        System.out.println(palindrome.solution2(num));
    }

    //使用api
    public boolean solution1(int num){
        return String.valueOf(num).equals(new StringBuilder(num+"").reverse().toString());
    }

    //使用双指针
    public boolean solution2(int num){
        String nums = num+"";
        int i = 0,j = nums.length()-1;

        while (i<j){
            if (nums.charAt(i)!=nums.charAt(j)){
                return false;
            }
            i++;
            j--;
        }

        return true;
    }
}
